<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
	<meta charset="utf-8" />
		<title>进票查询</title>		
		
			<script type="text/javascript" src="plugins/websocketInstantMsg/ext4/ext-all-debug.js"></script>
<script type="text/javascript" src="static/js/jquery-1.7.2.js" />
			<script type="text/javascript" src="plugins/websocketInstantMsg/ext4/locale/ext-lang-zh_CN.js"></script>
			<link rel="stylesheet" href="plugins/websocketInstantMsg/ext4/resources/css/ext-all.css" />
			
			
</head>
<body>

</body>
<script type="text/javascript">
Ext.onReady(function(){
	var store = Ext.create('Ext.data.Store', {
		fields: ["state","BUSINESS_TYPE","sale_name","COST_PLATE","invoice_code","currency","BILL_CODE","invoice_type",
		         "SETTLEMENT_CATEGORY","invoice_app_code","app_person_name","tax_price","exchange_rate","zehe"
		         ],
		pageSize: 30,  //页容量5条数据
		//是否在服务端排序 （true的话，在客户端就不能排序）
		remoteSort: false,
		remoteFilter: true,
		proxy: {
			type: 'ajax',
			url: '<%=basePath%>invoiceMgr/goTicketInfo',
			reader: {   //这里的reader为数据存储组织的地方，下面的配置是为json格式的数据，例如：[{"total":50,"rows":[{"a":"3","b":"4"}]}]
				type: 'json', //返回数据类型为json格式
				root: 'result.list',  //数据
				totalProperty: 'result.total' //数据总条数
			}
		},
		sorters: [{
			property: 'ordeId',
			direction: 'desc'
		}],
		autoLoad: true
	});
	var store1 = Ext.create('Ext.data.Store', {
		fields: ["now_state","BUSINESS_TYPE","title","COST_PLATE","code","currency","BILL_CODE","invoice_type",
		         "SETTLEMENT_CATEGORY","payment_code","app_person_name","tax_price","ratio","zehe"
		         ],
		pageSize: 30,  //页容量5条数据
		//是否在服务端排序 （true的话，在客户端就不能排序）
		remoteSort: false,
		remoteFilter: true,
		proxy: {
			type: 'ajax',
			url: '<%=basePath%>invoiceMgr/intoTicketData',
			reader: {   //这里的reader为数据存储组织的地方，下面的配置是为json格式的数据，例如：[{"total":50,"rows":[{"a":"3","b":"4"}]}]
				type: 'json', //返回数据类型为json格式
				root: 'result.list',  //数据
				totalProperty: 'result.total' //数据总条数
			}
		},
		sorters: [{
			property: 'ordeId',
			direction: 'desc'
		}],
		autoLoad: true
	});
	var findInvoice = Ext.create('Ext.data.Store', {
		fields: ["sale_name","invoice_code"
		         ],
		pageSize: 30,  //页容量5条数据
		//是否在服务端排序 （true的话，在客户端就不能排序）
		remoteSort: false,
		remoteFilter: true,
		proxy: {
			type: 'ajax',
			url: '<%=basePath%>invoiceMgr/findInvoice',
			reader: {   //这里的reader为数据存储组织的地方，下面的配置是为json格式的数据，例如：[{"total":50,"rows":[{"a":"3","b":"4"}]}]
				type: 'json', //返回数据类型为json格式
				root: 'result.list',  //数据
				totalProperty: 'result.total' //数据总条数
			}
		},
		sorters: [{
			property: 'ordeId',
			direction: 'desc'
		}],
		autoLoad: true
	});
	var findFeeType = Ext.create('Ext.data.Store', {
		fields: ["COST_PLATE"
		         ],
		pageSize: 30,  //页容量5条数据
		//是否在服务端排序 （true的话，在客户端就不能排序）
		remoteSort: false,
		remoteFilter: true,
		proxy: {
			type: 'ajax',
			url: '<%=basePath%>invoiceMgr/findFeeType',
			reader: {   //这里的reader为数据存储组织的地方，下面的配置是为json格式的数据，例如：[{"total":50,"rows":[{"a":"3","b":"4"}]}]
				type: 'json', //返回数据类型为json格式
				root: 'result.list',  //数据
				totalProperty: 'result.total' //数据总条数
			}
		},
		sorters: [{
			property: 'ordeId',
			direction: 'desc'
		}],
		autoLoad: true
	});
	var findBillCode = Ext.create('Ext.data.Store', {
		fields: ["BILL_CODE"
		         ],
		pageSize: 30,  //页容量5条数据
		//是否在服务端排序 （true的话，在客户端就不能排序）
		remoteSort: false,
		remoteFilter: true,
		proxy: {
			type: 'ajax',
			url: '<%=basePath%>invoiceMgr/findBillCode',
			reader: {   //这里的reader为数据存储组织的地方，下面的配置是为json格式的数据，例如：[{"total":50,"rows":[{"a":"3","b":"4"}]}]
				type: 'json', //返回数据类型为json格式
				root: 'result.list',  //数据
				totalProperty: 'result.total' //数据总条数
			}
		},
		sorters: [{
			property: 'ordeId',
			direction: 'desc'
		}],
		autoLoad: true
	});
	var findInvoiceAppCode = Ext.create('Ext.data.Store', {
		fields: ["invoice_app_code"
		         ],
		pageSize: 30,  //页容量5条数据
		//是否在服务端排序 （true的话，在客户端就不能排序）
		remoteSort: false,
		remoteFilter: true,
		proxy: {
			type: 'ajax',
			url: '<%=basePath%>invoiceMgr/findInvoiceAppCode',
			reader: {   //这里的reader为数据存储组织的地方，下面的配置是为json格式的数据，例如：[{"total":50,"rows":[{"a":"3","b":"4"}]}]
				type: 'json', //返回数据类型为json格式
				root: 'result.list',  //数据
				totalProperty: 'result.total' //数据总条数
			}
		},
		sorters: [{
			property: 'ordeId',
			direction: 'desc'
		}],
		autoLoad: true
	});
	var state = Ext.create('Ext.data.Store', {
		fields: ['state'],
		data : [
// 			{"state":"请选择"},
			{"state":"作废"},
			{"state":"冲红"},
			{"state":"开票"},
		]
	});
	var currency = Ext.create('Ext.data.Store', {
		fields: ['name'],
		data : [
// 			{"name":"请选择"},
			{"name":"USD"},
			{"name":"RMB"},
		]
	});
	var now_state = Ext.create('Ext.data.Store', {
		fields: ['state'],
		data : [
			{"state":"请选择"},
			{"state":"核对"},
			{"state":"认证抵扣"},
			{"state":"核销"},
		]
	});
	 //业务类型的下拉
	var tradeTypeStore = Ext.create('Ext.data.Store', {
		fields: ['id', 'name'],
		data : [
            {"id":"", "name":"选择业务类型"},
			{"id":"0", "name":"进口"},
			{"id":"1", "name":"出口"},
			{"id":"2", "name":"沿江内贸上"},
			{"id":"3", "name":"沿江内贸下"},
			{"id":"4", "name":"沿海内贸上"},
			{"id":"5", "name":"沿海内贸下"},
		]
	});
	  var c1 = Ext.create('Ext.container.Container', {
			layout: 'column',
			defaults: { labelAlign: 'left', labelWidth: 60 },
			items: [
				{id:"startDate1",xtype: 'combobox',  name: 'startDate1',value:'',editable: false,displayField: 'state', store:state,queryMode: 'local',valueField: 'state',padding: '5px', fieldLabel: '状态'},
				{id:"startDate2",xtype: 'combobox',  name: 'startDate2',value:'',editable: false,displayField: 'name', store:tradeTypeStore,queryMode: 'local',valueField: 'name',padding: '5px', fieldLabel: '业务类型'},
				{id:"startDate3",xtype: 'combobox',  name: 'startDate3',value:'',editable: false,displayField: 'sale_name', store:findInvoice,queryMode: 'local',valueField: 'sale_name',padding: '5px', fieldLabel: '发票抬头'},
				{id:"startDate4",xtype: 'combobox',  name: 'startDate4',value:'',editable: false,displayField: 'COST_PLATE', store:findFeeType,queryMode: 'local',valueField: 'COST_PLATE',padding: '5px', fieldLabel: '费用类别'},
				
// 				{id:"startDate3",xtype: 'textfield', name: 'startDate3',padding: '5px',fieldLabel: '快速检索码'},
// 				{id:"startDate4",xtype: 'textfield', name: 'startDate4', padding: '5px', fieldLabel: '箱型缩写'},
// 				{id:"startDate5",xtype: 'textfield', name: 'startDate5', padding: '5px', fieldLabel: '箱型名称'},

			]
		});
	  var bs = Ext.create('Ext.container.Container', {
			layout: 'column',
			defaults: { labelAlign: 'left', labelWidth: 60 },
			items: [
				{id:"startDate5",xtype: 'combobox',  name: 'startDate5',value:'',editable: false,displayField: 'invoice_code', store:findInvoice,queryMode: 'local',valueField: 'invoice_code',padding: '5px', fieldLabel: '发票号'},
				{id:"startDate6",xtype: 'combobox',  name: 'startDate6',value:'',editable: false,displayField: 'name', store:currency,queryMode: 'local',valueField: 'name',padding: '5px', fieldLabel: '币种'},
				{id:"startDate7",xtype: 'combobox',  name: 'startDate7',value:'',editable: false,displayField: 'BILL_CODE', store:findBillCode,queryMode: 'local',valueField: 'BILL_CODE',padding: '5px', fieldLabel: '托单号'},
				{id:"startDate8",xtype: 'combobox',  name: 'startDate8',value:'',editable: false,displayField: 'invoice_app_code', store:findInvoiceAppCode,queryMode: 'local',valueField: 'invoice_app_code',padding: '5px', fieldLabel: '发票申请号'},
				{layout : 'column',baseCls : 'my-panel-no-border',  padding: '5px',  items: [
					{ style: {marginRight:'10px'}, xtype: "button",minWidth:70,icon:'../plugins/websocketInstantMsg/ext4/shared/icons/fam/add.png', text: "查询",handler: function(){
			      		 	var state = Ext.getCmp('startDate1').getValue();
				      		var BUSINESS_TYPE = Ext.getCmp('startDate2').getValue();
				      		var sale_name = Ext.getCmp('startDate3').getValue();
				      		var COST_PLATE = Ext.getCmp('startDate4').getValue();
				      		var invoice_code = Ext.getCmp('startDate5').getValue();
				      		var currency = Ext.getCmp('startDate6').getValue();
				      		var BILL_CODE = Ext.getCmp('startDate7').getValue();
				      		var invoice_app_code = Ext.getCmp('startDate8').getValue();
		
				      		var store = Ext.getCmp('grid').getStore();
							store.on('beforeload', function(store,options) {  
						            var new_params = {  
						            		 state:encodeURI(state), BUSINESS_TYPE:encodeURI(BUSINESS_TYPE),sale_name:encodeURI(sale_name),COST_PLATE:encodeURI(COST_PLATE),invoice_code:encodeURI(invoice_code),
					        				 currency:encodeURI(currency),BILL_CODE:encodeURI(BILL_CODE),invoice_app_code:encodeURI(invoice_app_code)
						            };  
							//这里apply一下实现新的proxy  
						            Ext.apply(store.proxy.extraParams,new_params);  
						        });  
							//对store重新载入  
						        store.load();
				      	 } },
				],},
			]
		});
	
	
	var grid = Ext.create('Ext.grid.Panel', {
// 		renderTo:'payment',
		store: store,
		id:'grid',
		forceFit: true,
		height: 325,
		title:'出票信息',
		stripeRows:true,
		columnLines: true,
// 		plugins:[invoice_unit_cellEditing],
		selModel:Ext.create('Ext.selection.CheckboxModel',{mode:"single", allowDeselect: true, showHeaderCheckbox:false}),
		columns: [
			{text: '状态', dataIndex: 'state'},
			{text: '业务类型', dataIndex: 'BUSINESS_TYPE'},
			{text: '发票抬头', dataIndex: 'sale_name'},
			{text: '费用类别', dataIndex: 'COST_PLATE', align: 'left'},
			{text: '发票号', dataIndex: 'invoice_code'},
			{text: '币种', dataIndex: 'currency'},
			{text: '托单号', dataIndex: 'BILL_CODE'},
			{text: '发票类型', dataIndex: 'invoice_type'},
			{text: '结算类型', dataIndex: 'SETTLEMENT_CATEGORY'},
			{text: '发票申请单号', dataIndex: 'invoice_app_code'},
			{text: '申请人', dataIndex: 'app_person_name'},
			{text: '金额', dataIndex: 'tax_price'},
			{text: '汇率', dataIndex: 'exchange_rate'},
			{text: '折合人民币', dataIndex: 'zehe'},
		],
		bbar: [{
			xtype: 'pagingtoolbar',
			store: store,
			displayMsg: '显示 {0} - {1} 条，共计 {2} 条',
			emptyMsg: "没有数据",
			beforePageText: "当前页",
			afterPageText: "共{0}页",
			displayInfo: true
		}],

		tbar: [],
	listeners: {
		'itemclick': function (view, record, item, index, e) {
			var store = Ext.getCmp('grid1').getStore();
			store.on('beforeload', function(store,options) {  
		            var new_params = {  
		            		check_id:record.data.check_id
		            };  

		            Ext.apply(store.proxy.extraParams,new_params);  
		        });  
		        store.load();  
		}
	},
	});
	
	
	
	
	var findInvoiceTwo = Ext.create('Ext.data.Store', {
		fields: ["title","code"
		         ],
		pageSize: 30,  //页容量5条数据
		//是否在服务端排序 （true的话，在客户端就不能排序）
		remoteSort: false,
		remoteFilter: true,
		proxy: {
			type: 'ajax',
			url: '<%=basePath%>invoiceMgr/findInvoiceTwo',
			reader: {   //这里的reader为数据存储组织的地方，下面的配置是为json格式的数据，例如：[{"total":50,"rows":[{"a":"3","b":"4"}]}]
				type: 'json', //返回数据类型为json格式
				root: 'result.list',  //数据
				totalProperty: 'result.total' //数据总条数
			}
		},
		sorters: [{
			property: 'ordeId',
			direction: 'desc'
		}],
		autoLoad: true
	});
	var findFeeTypeTwo = Ext.create('Ext.data.Store', {
		fields: ["COST_PLATE"
		         ],
		pageSize: 30,  //页容量5条数据
		//是否在服务端排序 （true的话，在客户端就不能排序）
		remoteSort: false,
		remoteFilter: true,
		proxy: {
			type: 'ajax',
			url: '<%=basePath%>invoiceMgr/findFeeTypeTwo',
			reader: {   //这里的reader为数据存储组织的地方，下面的配置是为json格式的数据，例如：[{"total":50,"rows":[{"a":"3","b":"4"}]}]
				type: 'json', //返回数据类型为json格式
				root: 'result.list',  //数据
				totalProperty: 'result.total' //数据总条数
			}
		},
		sorters: [{
			property: 'ordeId',
			direction: 'desc'
		}],
		autoLoad: true
	});
	var findInvoiceAppCodeTwo = Ext.create('Ext.data.Store', {
		fields: ["payment_code"
		         ],
		pageSize: 30,  //页容量5条数据
		//是否在服务端排序 （true的话，在客户端就不能排序）
		remoteSort: false,
		remoteFilter: true,
		proxy: {
			type: 'ajax',
			url: '<%=basePath%>invoiceMgr/findInvoiceAppCodeTwo',
			reader: {   //这里的reader为数据存储组织的地方，下面的配置是为json格式的数据，例如：[{"total":50,"rows":[{"a":"3","b":"4"}]}]
				type: 'json', //返回数据类型为json格式
				root: 'result.list',  //数据
				totalProperty: 'result.total' //数据总条数
			}
		},
		sorters: [{
			property: 'ordeId',
			direction: 'desc'
		}],
		autoLoad: true
	});
	  var c2 = Ext.create('Ext.container.Container', {
			layout: 'column',
			defaults: { labelAlign: 'left', labelWidth: 60 },
			items: [
				{id:"startDate11",xtype: 'combobox',  name: 'startDate11',value:'',editable: false,displayField: 'state', store:now_state,queryMode: 'local',valueField: 'state',padding: '5px', fieldLabel: '状态'},
				{id:"startDate21",xtype: 'combobox',  name: 'startDate21',value:'',editable: false,displayField: 'BUSINESS_TYPE', store:tradeTypeStore,queryMode: 'local',valueField: 'BUSINESS_TYPE',padding: '5px', fieldLabel: '业务类型'},
				{id:"startDate31",xtype: 'combobox',  name: 'startDate31',value:'',editable: false,displayField: 'title', store:findInvoiceTwo,queryMode: 'local',valueField: 'title',padding: '5px', fieldLabel: '发票抬头'},
				{id:"startDate41",xtype: 'combobox',  name: 'startDate41',value:'',editable: false,displayField: 'COST_PLATE', store:findFeeTypeTwo,queryMode: 'local',valueField: 'COST_PLATE',padding: '5px', fieldLabel: '费用类别'},
			]
		});
	  var bs1 = Ext.create('Ext.container.Container', {
			layout: 'column',
			defaults: { labelAlign: 'left', labelWidth: 60 },
			items: [
				{id:"startDate51",xtype: 'combobox',  name: 'startDate51',value:'',editable: false,displayField: 'code', store:findInvoiceTwo,queryMode: 'local',valueField: 'code',padding: '5px', fieldLabel: '发票号'},
				{id:"startDate61",xtype: 'combobox',  name: 'startDate61',value:'',editable: false,displayField: 'name', store:currency,queryMode: 'local',valueField: 'name',padding: '5px', fieldLabel: '币种'},
				{id:"startDate71",xtype: 'combobox',  name: 'startDate71',value:'',editable: false,displayField: 'BILL_CODE', store:findBillCode,queryMode: 'local',valueField: 'BILL_CODE',padding: '5px', fieldLabel: '托单号'},
				{id:"startDate81",xtype: 'combobox',  name: 'startDate81',value:'',editable: false,displayField: 'payment_code', store:findInvoiceAppCodeTwo,queryMode: 'local',valueField: 'payment_code',padding: '5px', fieldLabel: '付款申请号'},
				{layout : 'column',baseCls : 'my-panel-no-border',  padding: '5px',  items: [
					{ style: {marginRight:'10px'}, xtype: "button",minWidth:70,icon:'../plugins/websocketInstantMsg/ext4/shared/icons/fam/add.png', text: "查询",handler: function(){
			      		 	var now_state = Ext.getCmp('startDate11').getValue();
				      		var BUSINESS_TYPE = Ext.getCmp('startDate21').getValue();
				      		var title = Ext.getCmp('startDate31').getValue();
				      		var COST_PLATE = Ext.getCmp('startDate41').getValue();
				      		var code = Ext.getCmp('startDate51').getValue();
				      		var currency = Ext.getCmp('startDate61').getValue();
				      		var BILL_CODE = Ext.getCmp('startDate71').getValue();
				      		var payment_code = Ext.getCmp('startDate81').getValue();
				      		var store = Ext.getCmp('grid1').getStore();
							store.on('beforeload', function(store,options) {  
						            var new_params = {  
						            		 now_state:encodeURI(now_state), BUSINESS_TYPE:encodeURI(BUSINESS_TYPE),title:encodeURI(title),COST_PLATE:encodeURI(COST_PLATE),code:encodeURI(code),
					        				 currency:encodeURI(currency),BILL_CODE:encodeURI(BILL_CODE),payment_code:encodeURI(payment_code)
						            };  
							//这里apply一下实现新的proxy  
						            Ext.apply(store.proxy.extraParams,new_params);  
						        });  
							//对store重新载入  
						        store.load();  
				      	 } },
				],},
			]
		});
	
	var grid1 = Ext.create('Ext.grid.Panel', {
// 		renderTo:'payment',
		store: store1,
		id:'grid1',
		forceFit: true,
		height: 325,
		title:'进票信息',
		stripeRows:true,
		columnLines: true,
// 		plugins:[invoice_unit_cellEditing],
		selModel:Ext.create('Ext.selection.CheckboxModel',{mode:"single", allowDeselect: true, showHeaderCheckbox:false}),
		columns: [
			{text: '状态', dataIndex: 'now_state'},
			{text: '业务类型', dataIndex: 'BUSINESS_TYPE'},
			{text: '发票抬头', dataIndex: 'title'},
			{text: '费用类别', dataIndex: 'COST_PLATE', align: 'left'},
			{text: '发票号', dataIndex: 'code'},
			{text: '币种', dataIndex: 'currency'},
			{text: '托单号', dataIndex: 'BILL_CODE'},
			{text: '发票类型', dataIndex: 'invoice_type'},
			{text: '结算类型', dataIndex: 'SETTLEMENT_CATEGORY'},
			{text: '付款申请单号', dataIndex: 'payment_code'},
			{text: '申请人', dataIndex: 'app_person_name'},
			{text: '金额', dataIndex: 'tax_price'},
			{text: '汇率', dataIndex: 'ratio'},
			{text: '折合人民币', dataIndex: 'zehe'},
		],
		bbar: [{
			xtype: 'pagingtoolbar',
			store: store1,
			displayMsg: '显示 {0} - {1} 条，共计 {2} 条',
			emptyMsg: "没有数据",
			beforePageText: "当前页",
			afterPageText: "共{0}页",
			displayInfo: true
		}],

		tbar: [
<%-- 			   {text: '否决', icon: '<%=basePath%>plugins/websocketInstantMsg/ext4/shared/icons/fam/control_rewind.png',handler: function(){}} --%>
		],
	listeners: {
		'itemclick': function (view, record, item, index, e) {
			var store = Ext.getCmp('grid1').getStore();
			store.on('beforeload', function(store,options) {  
		            var new_params = {  
		            		check_id:record.data.check_id
		            };  

		            Ext.apply(store.proxy.extraParams,new_params);  
		        });  
		        store.load();  
		}
	},
	});
	
	
	  var tabs = new Ext.TabPanel({
		  renderTo: Ext.getBody(),

            activeTab:0,
            deferredRender:true,

            items: [
                    { title: '出票查询',items:[c1,bs,grid],listeners: {  
                        'show': function (t, eOpts) {  
                        }  
                    }  },
                    { title: '进票查询',items:[c2,bs1,grid1],listeners: {  
                        'show': function (t, eOpts) {  
                        }  
                    }  }
            ]
        });
});

</script>
</html>